package com.boxin.ims.modules.sys.utils;

import java.util.Random;

import com.thinkgem.jeesite.common.utils.DateUtils;

/**
 * @author Administrator
 * @date 2014-4-24
 * @function <p> 随机数工具类</p>
 */
public class RandomUtils {
	
	public  static int randArrayInt(int scope){
		if(scope==0) return 0;
		
		Random rand = new Random();
		int r = rand.nextInt(scope);
		
		if(r==scope) r--;
		if(r<0) r=0;
		return r;
		
	}
	/**
	 * 
	 * @function: <p> 生成随机字符串</p>
	 * @param length
	 * @return
	 */
	public static String getRandomName(int length){
		StringBuilder sb = new StringBuilder();
		sb.append(DateUtils.getDateTimeString());
		Random rand = new Random();
		for (int i = 0; i < length; i++) {
			sb.append(rand.nextInt(10));
		}
		String data = sb.toString();
		return data;
	}
	public static void main(String[] args) {
		for(int i =1;i<10;i++){
			System.out.println(randArrayInt(20));
		}
	}

}
